package org.ruanjj.multithread;


//创建线程的第一种方法
//继承Thread重写Tread的run方法，然后创建当前子类的对象调start方法
public class ThreadDemo1 extends Thread {
    @Override
    public void run(){
        for(int i = 0; i < 100; i++){
            if(i%2 == 0){
                System.out.println(Thread.currentThread().getName()+":"+i);
            }
        }
    }
}


class ThreadDemo1Test{
    public static void main(String[] args) {
        ThreadDemo1 treadDemo1 = new ThreadDemo1();
        treadDemo1.start();

        ThreadDemo1 treadDemo2 = new ThreadDemo1();
        treadDemo2.start();

        for(int i = 0; i < 100; i++){
            if(i%2 == 0){
                System.out.println(Thread.currentThread().getName()+":"+i);
            }
        }
    }
}